package org.cunamas.core.dao.impl;

import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;
import javax.sql.DataSource;

import org.cunamas.core.dao.ReporteTotalProtegidosSo3Dao;
import org.cunamas.core.dto.Filtros;
import org.cunamas.core.dto.ReporteTotalProtegidosSo3Dto;
import org.cunamas.core.dto.mapper.ReporteTotalProtegidosSo3Mapper;
import org.cunamas.web.util.CunamasConstants;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.SqlReturnResultSet;
import org.springframework.jdbc.object.StoredProcedure;
import org.springframework.stereotype.Component;

@Component
public class ReporteTotalProtegidosSo3DaoProcedureImpl extends StoredProcedure implements ReporteTotalProtegidosSo3Dao {

	public static final String SPROC_NAME = CunamasConstants.SP_REPORTE_TOTAL_PROTEGIDOS_SO3_3;
	
	public static final String ANO = "ANO";
	public static final String MES = "MES";
	public static final String DIA = "DIA";
	public static final String CODPRG = "CODPRG";

	
	@Inject
	public ReporteTotalProtegidosSo3DaoProcedureImpl(DataSource dataSource){
		super(dataSource, SPROC_NAME);
		declareParameter(new SqlReturnResultSet("rs", new ReporteTotalProtegidosSo3Mapper()));
		declareParameter(new SqlParameter(ANO, Types.VARCHAR));
		declareParameter(new SqlParameter(MES, Types.VARCHAR));
	    declareParameter(new SqlParameter(DIA, Types.VARCHAR));
	    declareParameter(new SqlParameter(CODPRG, Types.VARCHAR));
	    
	    compile();
	}
	
	

	public List<ReporteTotalProtegidosSo3Dto> retornaReporteTotalProtegidosSo3Dto(Filtros filtros){
		Map<String, Object> inputs = new HashMap<String, Object>();
		inputs.put(ANO, filtros.getAnio());
	    inputs.put(MES, filtros.getMes());
	    inputs.put(DIA, filtros.getDia());
	    inputs.put(CODPRG, filtros.getCodProg());
	    Map output= super.execute(inputs);
		return (ArrayList<ReporteTotalProtegidosSo3Dto>)output.get("rs");
	}
	
	
}
